﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Ninject;
using Ninject.Modules;

namespace CoolCode.Ioc
{
    public class Combiner : IDiggable
    {
        private IInjectable[] _injectors;

        private IKernel kernel;

        //public Combiner(params IInjectable[] injectors)
        //{
        //    _injectors = injectors;
        //}

        //private Ninject.Modules.INinjectModule[] ToNinjectModule(IInjectable[] injectors)
        //{

        //}

        public Combiner(params  Injector[] injectors)
        {
            _injectors = injectors;
            INinjectModule[] modules = ToNinjectModule(injectors);
            kernel = new StandardKernel(modules);
        }

        private INinjectModule[] ToNinjectModule(Injector[] injectors)
        { 
            return injectors.Select(c => c.ToNinjectModule()).ToArray();
        }

        #region IDiggable Members

        public T Dig<T>()
        {
            return kernel.Get<T>();
        } 

        #endregion
    }
}
